import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Random;

public class CardList {
    private ArrayList<Card> cardList = new ArrayList<>();
    private String[] img = {"♥","♠","♦","♣"};
    public CardList() {
        for (int i = 0; i < 4; i++) {
            for (int j = 1; j <= 13; j++) {
                cardList.add(new Card(j,img[i]));
            }
        }
    }

    public void find() {
        for (int i = 0; i < cardList.size(); i++) {
            System.out.print(cardList.get(i) + " ");
        }
        System.out.println();
    }
    public void shuffle() {
        Random random = new Random();
        for (int i = cardList.size() - 1; i > 0 ; i--) {
            int num = random.nextInt(i);//num随机范围:[0,i)

            Card cmp = cardList.get(i);
            cardList.set(i,cardList.get(num));
            cardList.set(num,cmp);
        }
    }
    public void licensing () {
        ArrayList<Card> p1 = new ArrayList<>();
        ArrayList<Card> p2 = new ArrayList<>();
        ArrayList<Card> p3 = new ArrayList<>();

        ArrayList<ArrayList<Card>> ppp = new ArrayList<>();
        ppp.add(p1);
        ppp.add(p2);
        ppp.add(p3);

        int cont = 0;
        for (int i = 0; i < 5; i++) {
            for (int j = 0; j < 3; j++) {
                ppp.get(j).add(cardList.get(cont++));
            }
        }

        for (int i = 0; i < ppp.size(); i++) {
            System.out.print("p" + (i+1) + ": ");
            for (int j = 0; j < ppp.get(i).size(); j++) {
                System.out.print(ppp.get(i).get(j) + " ");
            }
            System.out.println();
        }

    }
}
